using System;

using TrueCode.Core.Diagnostics;

namespace TrueCode.Core
{
	public static class ArrayExtensions
	{
		public static bool TrueForAll< T >(this T[] array, Predicate< T > match)
		{
			ExceptionHelper.ThrowIfArgumentIsNull< T[] >(array, "array");
			ExceptionHelper.ThrowIfArgumentIsNull< T[] >(match, "match");
			for( int i = 0; i < array.Length; i++ )
			{
				if( !match(array[i]) )
				{
					return false;
				}
			}
			return true;
		}
	}
}